#include <myheader_c_plus.h>
using std::cout;
using std::endl;
class Point{
private:
    int _x;
    int _y;
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {

    }

    operator int(){
        return _x + _y;
    }

    //赋值运算符函数
    Point & operator=(const Point & rhs){
        cout << "operator=(const Point & rhs)" << endl;
        _x = rhs._x;
        _y = rhs._y;
        return *this;
    }

};

class Complex{
private:
    int _real;
    int _image;
public:
    Complex(int real, int image)
    :_real(real)
    ,_image(image)
    {

    }

    //类型转换函数
    operator Point(){
        return Point(_real, _image);
    }

};
int main(int argc, char *argv[])
{
    Point pt(1,3);
    int a = pt;
    Complex ex(2,3);
    cout << a << endl;
    //将Complex 转换成Point,并且调用赋值运算符函数
    pt = ex;
    a = pt;
    cout << a << endl; 
    return 0;
}

